package mtn.bowen.yan.server.common;

import mtn.bowen.yan.server.enums.ErrorCode;

/**
 * @author <a href=mailto:yanbowen90@foxmail.com> bowen.yan </a>
 * @version 1.0
 * @description: TODO
 * @date 2021-10-22 11:17 AM
 */
public class JsonResult<T> {

    private int status;
    private String msg;
    private T data;

    public JsonResult() {
    }

    public JsonResult(int status, String msg, T data) {
        this.status = status;
        this.msg = msg;
        this.data = data;
    }

    public JsonResult(ErrorCode errorCode, T data) {
        this.status = errorCode.getCode();
        this.msg = errorCode.getMsg();
        this.data = data;
    }

    public JsonResult(ErrorCode errorCode) {
        this.status = errorCode.getCode();
        this.msg = errorCode.getMsg();
        this.data = null;
    }

    public int getStatus() {
        return status;
    }

    public void setStatus(int status) {
        this.status = status;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public T getData() {
        return data;
    }

    public void setData(T data) {
        this.data = data;
    }
}

